<?php
include_once('header.inc.php');
if(!ereg('^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$', $_POST['mail']))
   redirection('compte.php?err=E-mail incorrect');
if(!@checkdate($_POST['mm'],$_POST['jj'],$_POST['aaaa']) || $_POST['aaaa']>date('Y'))
   redirection('compte.php?err=Date de naissance incorrecte');
if(!empty($_POST['newpass']))
	$data['pass'] = md5($_POST['newpass']);
$data['mail'] = $_POST['mail'];
$data['firstname'] = ucfirst(strtolower($_POST['firstname']));
$data['lastname'] = ucfirst(strtolower($_POST['lastname']));
$data['birthdate'] = $_POST['aaaa'].'-'.$_POST['mm'].'-'.$_POST['jj'];
$data['notifications'] = $_POST['notifications']=='on' ? '1' : '0';
$data['public_one'] = $_POST['public_one']=='on' ? '1' : '0';
$data['public_all'] = $_POST['public_all']=='on' ? '1' : '0';
$db->update($CONFIG['table_users'], $data, 'login=\''.$_SESSION['login'].'\'');
redirection('compte.php?ok');
?>